package com.you.pattern.observer.demo1;

public class Main {

    public static void main(String[] args) {
        //创建被观察者
        GPer gPer = GPer.getInstance();
        //创建观察者
        Teacher tom = new Teacher("tom");
        Teacher james = new Teacher("james");
        gPer.addObserver(tom);
        gPer.addObserver(james);

        //业务逻辑代码
        Question question = new Question();
        question.setUserName("小明");
        question.setContent("观察者模式适用于哪些场景？");

        gPer.publishQuestion(question);
    }
}
